#include "stdafx.h"
#include "CppUnitTest.h"
#include <iostream>

using namespace std;
using namespace Microsoft::VisualStudio::CppUnitTestFramework;

namespace NativeTest_Qestion6
{

	void swap(int &a, int &b){
		int t = a;
		a = b;
		b = t;
	}
	void transpose(int a[][4], int n){
		for(int i=0; i<n; ++i)
			for(int j=i+1; j<n; ++j)
				swap(a[i][j], a[j][i]);

		for(int i=0; i<n/2; ++i)
			for(int j=0; j<n; ++j)
				swap(a[i][j], a[n-1-i][j]);
	}

	void mytransport(int a[][4], int n)
	{
		for (int i = 0; i < n/2; i++)
		{
			for (int j = i; j < n-1-i; j++)
			{
				int t = a[i][j];
				a[i][j] = a[n-1-j][i];
				a[n-1-j][i] = a [n-1-i][n-1-j];
				a[n-1-i][n-1-j] = a[j][n-1-i];
				a [j][n-1-i] = t;
			}
		}
	}
}
namespace NativeTest
{
	using namespace NativeTest_Qestion6;
	TEST_CLASS(Question6)
	{
	public:

		TEST_METHOD(Question6_TestMethod1)
		{

			int a[4][4] = {
				{1, 2, 3, 4},
				{5, 6, 7, 8},
				{9, 10, 11, 12},
				{13, 14, 15, 16}
			};
			for(int i=0; i<4; ++i){
				for(int j=0; j<4; ++j)
					cout<<a[i][j]<<" ";
				cout<<endl;
			}
			cout<<endl;
			transpose(a, 4);

			for(int i=0; i<4; ++i){
				for(int j=0; j<4; ++j)
					cout<<a[i][j]<<" ";
				cout<<endl;
			}
		}

	};
}